import java.util.*;

class Person{
    public String id;

    public Person(String id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return Objects.equals(id, person.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}
public class Test {
    public List<String> topKFrequent(String[]words,int k){
        HashMap<String,Integer>map=new HashMap<>();
        //统计每个单词出现的次数
        for(String word:words){
            if(map.get(word)==null){
                map.put(word,1);
            }else{
                int val=map.get(word);
                map.put(word,val+1);
            }
        }
        //建立小根堆
        PriorityQueue<Map.Entry<String ,Integer>> minHeap=new PriorityQueue<>(new Comparator<Map.Entry<String, Integer>>() {
            @Override
            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                if(o1.getValue().compareTo(o2.getValue())==0){
                    return o2.getKey().compareTo(o1.getKey());
                }
                return o1.getValue().compareTo(o2.getValue());
            }
        });
        //遍历Map
        for(Map.Entry<String,Integer>entry:map.entrySet()){
            if(minHeap.size()<k){
                minHeap.offer(entry);
            }else {
                Map.Entry<String,Integer> top=minHeap.peek();
                if(top.getValue().compareTo(entry.getValue())<0){
                    minHeap.poll();
                    minHeap.offer(entry);
                }else if(top.getValue().compareTo(entry.getValue())==0){
                    if(top.getKey().compareTo(entry.getKey())>0){
                        minHeap.poll();
                        minHeap.offer(entry);
                    }
                }
            }
        }
        //把这个小根堆的每一个结点取出来放到一个链表中
        ArrayList<String> list=new ArrayList<>();
        for(int i=0;i<k;i++){
            Map.Entry<String,Integer> tmp=minHeap.poll();
            list.add(tmp.getKey());
        }
        //最后逆置这个链表让他从小到大
        Collections.reverse(list);
        return list;
    }
    public static void main(String[] args) {
        //统计一篇文章出现频率高的单词


    }
    public static void func(String str1,String str2){
        str1=str1.toUpperCase();
        str2=str2.toUpperCase();
        HashSet<Character> setAct=new HashSet<>();
        for(int i=0;i<str2.length();i++){
            char ch=str2.charAt(i);
            setAct.add(ch);
        }
        HashSet<Character> setBroken=new HashSet<>();//存放坏了的键
        for(int i=0;i<str1.length();i++){
            char ch=str1.charAt(i);
            if(!setAct.contains(ch)&&!setBroken.contains(ch)){  //如果setact中不包含ch说明这个ch是坏了的键
                setBroken.add(ch);
                System.out.print(ch+" ");
            }
        }
    }
    public static void main7(String[] args) {
        //坏键盘打字
        //输入两个字符串
        Scanner in=new Scanner(System.in);
        //注意hasNext和hasNextLine的区别
        while(in.hasNextLine()){
            String str1=in.nextLine();
            String str2=in.nextLine();
            func(str1,str2);
        }
    }


    public static int numjewelsInStones(String jewels,String stones){
        HashSet<Character>set=new HashSet<>();
      for(int i=0;i<jewels.length();i++){
          char ch=jewels.charAt(i);
          set.add(ch);
      }
      int count=0;
        for(int i=0;i<stones.length();i++){
            char ch=stones.charAt(i);
            if(set.contains(ch)){
                count++;
            }
        }
        return count;
    }
    public static void main6(String[] args) {
        //宝石与石头
        String jewels="aA";
        String stones="aAbbbbb";
        int num=numjewelsInStones(jewels,stones);
        System.out.println(num);
    }
    public static void main5(String[] args) {
        //给你一个链表这个链表中有下一个结点的地址，还有一个随机结点的地址
        //让你对这个链表进行深拷贝，就是创建一个新的链表把这个链表的的对应关系也一一进行拷贝而创建一个全新的链表
        //copylist
    }
    public static int singleNumber(int[]nums){
        HashSet<Integer> set=new HashSet<>();
        for(int i=0;i<nums.length;i++){
            if(set.contains(nums[i])){
                set.remove(nums[i]);
            }else{
                set.add(nums[i]);
            }
        }
        for(int i=0;i<nums.length;i++){
            if(set.contains(nums[i])){
                return nums[i];
            }
        }
        return -1;
    }
    public static void main4(String[] args) {
        //找出数组中只出现过一次的数字
        int[] nums={1,2,3,4,1,2,3,4,5,5,6};
        int single=singleNumber(nums);
        System.out.println(single);
    }
    public static Map<String,Integer> countWord(String[]words){
        Map<String,Integer> map=new HashMap<>();
        for(int i=0;i< words.length;i++){  //这一步是遍历words这个数组的内容
            if(map.get(words[i])==null){   //这一步是在哈希表中查找有没有这个单词，如果没有的话就把他当作单词出现一次存入哈希表中
                map.put(words[i],1);
            }else{
                int val=map.get(words[i]); //这个过程会进行拆箱
                map.put(words[i],val+1);
            }
        }
        return map;
    }
    public static void main3(String[] args) {
        //统计一篇文章中每个单词出现的数量
        String[]words={"hello","abc","hello","def","this","this","this"};
        Map<String,Integer>map=countWord(words);
        Set<Map.Entry<String,Integer>> entrySet=map.entrySet();
        for(Map.Entry<String,Integer> entry:entrySet){
            System.out.println("key:"+entry.getKey()+" val:"+entry.getValue());
        }
    }
    public static void main2(String[] args) {
        Person person1=new Person("1234");
        Person person2=new Person("2345");
        Person person3=new Person("3456");
        Person person4=new Person("3456");
       // System.out.println(person3.equals(person4));//重写hashcode之后才会等于true
        HashBuck2<Person,String> hashBuck2=new HashBuck2<>();
        hashBuck2.push(person1,"xiaoming");
        System.out.println(hashBuck2.getVal(person1));
    }
    public static void main1(String[] args) {
        HashBuck hashBuck=new HashBuck();
        hashBuck.push(1,111);
        hashBuck.push(11,111111);
        hashBuck.push(14,141414);
        hashBuck.push(4,444);
        hashBuck.push(2,222);
        hashBuck.push(15,151515);
        hashBuck.push(6,666);
        hashBuck.push(5,555);
        System.out.println(hashBuck.getval(15));

    }
}
